//
//  UIBarButtonItem.swift
//  Inpro
//
//  Created by 彭灿 on 16/9/20.
//  Copyright © 2016年 Roble. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    /// 创建 UIBarButtonItem
    ///
    /// - parameter title:            title
    /// - parameter fontSize:         fontSize 默认16号
    /// - parameter target:           target
    /// - parameter action:           action  将要执行的动作
    /// - parameter normalColor:      normalColor 默认黑色
    /// - parameter highlightedColor: highlightedColor 高亮颜色设置
    ///
    /// - returns: UIBarButtonItem
    convenience init(title: String, fontSize: CGFloat = 16, target: AnyObject?, action: Selector, isBack:Bool = false) {
        let btn = UIButton()
        btn.setTitle(title, for: .normal)
        /// 设置按钮高亮颜色
        // 未点击
        btn.setTitleColor(UIColor.darkGray, for: .normal)
        // 点击中
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        
        
        btn.frame = CGRect.init(x: 0, y: 0, width: 60, height: 40)
        btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: fontSize)
        
        btn.addTarget(target, action: action, for: .touchUpInside)
        // 实例化 UIBarButtonItem
        self.init(customView: btn)
        
//        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn)
    }
}
